﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Root.master" AutoEventWireup="true" CodeFile="payments.aspx.cs" Inherits="Default2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Content" runat="Server">
    <script src="../Scripts/toolbar.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        // <![CDATA[

        function OnkontrChanged(cmbCountry) {
            grdPayment.GetEditor("DOG").PerformCallback(cmbCountry.GetValue().toString());
        }

        function onExport() {
            Callback.PerformCallback('1');
        }

        function onMenuClick(s, e) {
            switch (e.item.index) {
                case 3: //создать счет
                    //Callback.PerformCallback('1');
                    ppc1.Show();
                    break;
                default: MenuItemClick(e, grdPayment);
            }
        }
        // ]]>
    </script>
    <div class="pageLabel">
        <dx:ASPxLabel ID="lbl_page" runat="server" Text="Периодические платежи в разрезе договоров" Font-Size="Medium" Theme="iOS">
        </dx:ASPxLabel>
    </div>
    <div style="float: left; margin-left: 10px; margin-right: 10px;">
        <dx:ASPxMenu ID="mMenu" runat="server" EnableViewState="False" EncodeHtml="False" SeparatorWidth="2px" BackColor="Transparent"
            SeparatorHeight="15px" ItemSpacing="1px">
            <SeparatorBackgroundImage ImageUrl="~\Images\shared\ToolBars\Office2003\SeparatorBackground.png" />
            <ClientSideEvents ItemClick="function(s, e) { onMenuClick(s, e); }" />
            <Items>
                <dx:MenuItem Name="btn_Insert" Text="" ToolTip="Добавить запись" GroupName="grp_edit" BeginGroup="True">
                    <Image Url="~/Images/shared/edit_add.png">
                    </Image>
                </dx:MenuItem>
                <dx:MenuItem GroupName="grp_edit" Name="btn_edit" Text="" ToolTip="Редактировать запись">
                    <Image Url="~/Images/shared/edit.png" UrlDisabled="~/Images/shared/edit_disable.png">
                    </Image>
                </dx:MenuItem>
                <dx:MenuItem GroupName="grp_edit" Name="btn_Delete" Text="" ToolTip="Удалит запись">
                    <Image Url="~/Images/shared/editdelete.png" UrlDisabled="~/Images/shared/editdelete_disable.png">
                    </Image>
                </dx:MenuItem>
                <dx:MenuItem Text="">
                    <Image ToolTip="Создать счет" Url="~/Images/shared/apply.png">
                    </Image>
                </dx:MenuItem>
            </Items>
        </dx:ASPxMenu>

        <dx:ASPxGridView ID="grdPayment" ClientInstanceName="grdPayment" runat="server" AutoGenerateColumns="False" DataSourceID="ds_SrvShablon" KeyFieldName="CODE"
            OnRowInserting="grdPayment_RowInserting"
            OnCellEditorInitialize="grdPayment_CellEditorInitialize">
            <Columns>
                <dx:GridViewDataTextColumn FieldName="CODE" ReadOnly="True" VisibleIndex="0" Caption="Код">
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataComboBoxColumn Caption="Услуга" FieldName="SERVICES" VisibleIndex="1">
                    <PropertiesComboBox DataSourceID="ds_Services" TextField="NAME" ValueField="CODE" ValueType="System.Int32">
                    </PropertiesComboBox>
                    <EditFormSettings VisibleIndex="0" />
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataSpinEditColumn Caption="Тариф" FieldName="TARIF" VisibleIndex="2">
                    <PropertiesSpinEdit DisplayFormatString="g">
                    </PropertiesSpinEdit>
                    <EditFormSettings VisibleIndex="2" />
                </dx:GridViewDataSpinEditColumn>
                <dx:GridViewDataSpinEditColumn Caption="Объем" FieldName="QUANTITY" VisibleIndex="3">
                    <PropertiesSpinEdit DisplayFormatString="g">
                    </PropertiesSpinEdit>
                    <EditFormSettings VisibleIndex="4" />
                </dx:GridViewDataSpinEditColumn>
                <dx:GridViewDataComboBoxColumn Caption="Договор №" FieldName="DOG" VisibleIndex="5">
                    <PropertiesComboBox DataSourceID="ds_dog" TextField="NOMDOG" ValueField="CODE">
                    </PropertiesComboBox>
                    <EditFormSettings VisibleIndex="3" />
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataComboBoxColumn Caption="Организация" FieldName="KONTRAGENT" VisibleIndex="4">
                    <PropertiesComboBox DataSourceID="ds_kontr" TextField="NAME" ValueField="CODE" ValueType="System.Int32">
                        <ClientSideEvents SelectedIndexChanged="function(s, e) { OnkontrChanged(s);}"
                            ButtonClick="function(s, e) { s.SetSelectedIndex(-1); grdPayment.GetEditor('DOG').PerformCallback(-1); }" />
                        <Buttons>
                            <dx:EditButton Text="X" ToolTip="очистить">
                            </dx:EditButton>
                        </Buttons>
                    </PropertiesComboBox>
                    <EditFormSettings VisibleIndex="1" />
                </dx:GridViewDataComboBoxColumn>
            </Columns>
            <SettingsBehavior AllowFocusedRow="True" ConfirmDelete="True" EnableCustomizationWindow="true" AllowSelectByRowClick="True" AllowSelectSingleRowOnly="True" />
            <SettingsPager AlwaysShowPager="True">
                <PageSizeItemSettings Visible="True">
                </PageSizeItemSettings>
            </SettingsPager>
        </dx:ASPxGridView>
        <asp:EntityDataSource ID="ds_SrvShablon" runat="server" ConnectionString="name=RegistRar" DefaultContainerName="RegistRar" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="SRVSHABLON">
        </asp:EntityDataSource>
        <asp:EntityDataSource ID="ds_kontr" runat="server" ConnectionString="name=RegistRar" DefaultContainerName="RegistRar" EnableFlattening="False" EntitySetName="KONTRAGENT" Select="it.[CODE], it.[NAME]">
        </asp:EntityDataSource>
        <dx:ASPxPopupControl ID="ppc1" ClientInstanceName="ppc1" runat="server" Height="124px" Width="229px" HeaderText="Дата выписки счета" Modal="True" AllowDragging="True" AutoUpdatePosition="True" PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" Theme="DevEx" ShowFooter="True">
            <FooterStyle HorizontalAlign="Right" />
            <FooterTemplate>
                <div align="right">
                    <dx:ASPxButton ID="btnOk" runat="server" Text="Подтвердить" OnClick="btnOk_Click" Theme="BlackGlass"></dx:ASPxButton>
                </div>
            </FooterTemplate>
            <ContentCollection>
                <dx:PopupControlContentControl runat="server" SupportsDisabledAttribute="True">
                    <table>
                        <tr>
                            <td>
                                <dx:ASPxDateEdit ID="dtSchet" runat="server" HelpText="дата выпски счета">
                                    <HelpTextSettings Position="Top">
                                    </HelpTextSettings>
                                    <ValidationSettings Display="Dynamic">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                </dx:ASPxDateEdit>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <dx:ASPxSpinEdit ID="snomer" runat="server" Height="21px" Number="0" HelpText="номер счета" NumberType="Integer">
                                    <HelpTextSettings Position="Top">
                                    </HelpTextSettings>
                                    <ValidationSettings Display="Dynamic">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                </dx:ASPxSpinEdit>
                            </td>
                        </tr>
                    </table>
                </dx:PopupControlContentControl>
            </ContentCollection>
        </dx:ASPxPopupControl>
        <asp:EntityDataSource ID="ds_dog" runat="server" ConnectionString="name=RegistRar" DefaultContainerName="RegistRar" EnableFlattening="False" EntitySetName="DOG" Select="it.[CODE], it.[NOMDOG], it.[KONTRAGENT]" Where="">
        </asp:EntityDataSource>
        <asp:EntityDataSource ID="ds_Services" runat="server" ConnectionString="name=RegistRar" DefaultContainerName="RegistRar" EnableFlattening="False" EntitySetName="SERVICES">
        </asp:EntityDataSource>
    </div>
    <dx:ASPxGridViewExporter ID="Exporter" runat="server" GridViewID="grdPayment">
    </dx:ASPxGridViewExporter>
    <dx:ASPxCallback ID="Callback" ClientInstanceName="Callback" runat="server" OnCallback="Callback_Callback"></dx:ASPxCallback>
</asp:Content>

